import request from './request'

interface ILoginParams {
    username?: string | number;
    password?: string | number;
}

interface IRegisterParams {
    username?: string | number;
    password: string | number;
    email:  string;
    codeid:  number;
    code:  number;
}

interface IVerificationApiParams {
    e_mail?: string;
}

// 注册
export const RegisterApi = (params: IRegisterParams) => request.post('/register', params)

// 注册 验证码
export const VerificationApi = (params: IVerificationApiParams) => request.post('register/verification', params)

// 忘记密码
export const ForgetPwApi = (params: IRegisterParams) => request.post('/forgetPassword', params)

// 忘记密码 验证码
export const ForgetPwVfApi = (params: any) => request.post('forgetPassword/verification', params)

// 登录
export const LoginApi = (params: ILoginParams) => request.post('/login', params)

// 获取用户信息
export const  UserInfoApi = ()  => request.get('/info')

// 修改用户信息
export const  chengeUserInfoApi = (params: ILoginParams)  => request.post('/info',params)

// 文章列表
export const  GetArticleListApi = (params:{ current:number,
    counts:number})  => request.post('article/list',params)

// 根据id获取文章
export const GetArticleByIdApi = (params:{id:number})  => request.post(`
article/list/id`,params)

// 文章编辑接口
interface IEditArticleApi{
    id?:number;
    title:string;
    subTitle:string;
    content:string;
}
export const EditArticleApi = (params:IEditArticleApi)  => request.post(`
article/list/edit`,params)

// 文章删除接口
export const DeleteArticleApi = (params:{id:number})  => request.post(`
article/list/delelt`,params)

// 文章添加接口
export const AddAricleApi = (params:IEditArticleApi)  => request.post(`
article/list/add`,params)


// 获取小编名单
export const EditoApi = ()  => request.get(`
namelist/list`)

// 获取管理员名单
export const AdminEditoApi = ()  => request.get(`
namelist/adminList`)

interface IChangeEditoApi {
    id:number;
    open:number
}

// 获取小编名单
export const ChangeEditoApi = (params:IChangeEditoApi)  => request.post(`
namelist/update`,params)

export const ChangeAdminEditoApi = (params:IChangeEditoApi)  => request.post(`
namelist/adimnUpdate`,params)